Micron Document
🎖️GitЯра🎖️


Displaying Raw • View renderedDownload

docs/decisions/ble-strategy.md copilot/create-implementation-plan (228d872f) Text, 2.08 KB

Tc9d1d9# Decision: BLE KMP Strategy

Tff7b72> Date: 2026-03-16 | Status: **Decided — Fully Migrated to Kable**

Tc9d1d9## Context

Ta5d6ff`core:ble` needed to support non-Android targets. Nordic's Kotlin-BLE-Library, while mature on Android and actively tested in the app, was primarily Android/iOS focused and lacked support for Desktop (JVM) targets. Kable natively supports all Kotlin Multiplatform targets (Android, Apple, Desktop/JVM, Web).

Initially, we implemented an **Interface-Driven "Nordic Hybrid" Abstraction** (keeping Nordic on Android behind Ta5d6ff`commonMain` interfaces) to wait and see if Nordic expanded their KMP support.

However, as Desktop integration advanced, we found the need for a unified BLE transport.

Tc9d1d9## Decision

**Migrate entirely to Kable:**

Tff7b72- We migrated all BLE transport logic across Android and Desktop to use Kable.
Tff7b72- The Ta5d6ff`commonMain` interfaces (Ta5d6ff`BleConnection`, Ta5d6ff`BleScanner`, Ta5d6ff`BleDevice`, Ta5d6ff`BluetoothRepository`, etc.) remain, but their core implementations (Ta5d6ff`KableBleConnection`, Ta5d6ff`KableBleScanner`) are now entirely shared in Ta5d6ff`commonMain`.
Tff7b72- The Android-specific Nordic dependencies (Ta5d6ff`no.nordicsemi.kotlin.ble:*`) and the Nordic DFU library were completely excised from the project.
Tff7b72- OTA Firmware updates were successfully refactored to use the Kable-based Ta5d6ff`BleOtaTransport`, shared across Android and Desktop in Ta5d6ff`commonMain`.
Tff7b72- Nordic Secure DFU was reimplemented as a pure KMP protocol stack (Ta5d6ff`SecureDfuTransport`, Ta5d6ff`SecureDfuProtocol`, Ta5d6ff`SecureDfuHandler`) using Kable, with no dependency on the Nordic DFU library.

Tc9d1d9## Consequences

Tff7b72- **Maximal Code Deduplication:** The BLE implementation is completely shared across Android and Desktop in Ta5d6ff`core:ble/commonMain`.
Tff7b72- **Future-Proofing:** Adding an Ta5d6ff`iosMain` target in the future will be trivial, as it can leverage the same shared Kable abstractions.
Tff7b72- **Lost Nordic Mocks:** Kable lacks the comprehensive mock infrastructure of the Nordic library. Consequently, several complex BLE OTA unit tests had to be deprecated. Re-establishing this test coverage using custom Kable fakes is an ongoing technical debt item.

Served by rngit 1.5.0 - Generated in 0.09s